//
//  ViewController.m
//  CalculateStringSize
//
//  Created by lirenqiang on 2016/11/3.
//  Copyright © 2016年 1111. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *str = @"时间不曾欺骗我";
    UILabel *l1 = [UILabel new];
    l1.font = [UIFont systemFontOfSize:12];
    [self.view addSubview:l1];
    
}

- (CGSize)sizeUsingLabelWith:(NSString *)str
{
    UILabel *lbl = [UILabel new];
    lbl.text = str;
    lbl.font = [UIFont systemFontOfSize:12];
    [lbl sizeToFit];
    return lbl.frame.size;
    
}

- (CGSize)sizeUsingBoundingWithString:(NSString *)str
{
    return [str boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :[UIFont systemFontOfSize:12]} context:nil].size;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
